package com.yuncheng.oaApi.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.yuncheng.common.utils.ExcelUtil;
import com.yuncheng.vo.HttpResult;
import com.yuncheng.common.query.QueryBuilder;
import com.yuncheng.annotation.AutoLog;
import com.yuncheng.common.base.controller.BaseController;
import com.yuncheng.utils.I18nUtil;
import com.yuncheng.oaApi.entity.OaBgypsqgl;
import com.yuncheng.oaApi.service.IOaBgypsqglService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.yuncheng.system.api.SystemAPI;
import org.springframework.context.annotation.Lazy;

/**
 * @Description: 办公用品申请管理
 * @Author: lhb
 * @Date: 2023-08-07
 * @Version: V1.0
 */
@Api(tags = "办公用品申请管理接口")
@RestController
@RequestMapping("/api/spzx-oa/oaBgypsqgl")
public class OaBgypsqglController extends BaseController<OaBgypsqgl, IOaBgypsqglService> {

    private static final Logger log = LoggerFactory.getLogger(OaBgypsqglController.class);

    @Resource
    private IOaBgypsqglService oaBgypsqglService;

    @Resource
    @Lazy
    private SystemAPI systemAPI;


    /**
     * 分页列表查询
     *
     * @param oaBgypsqgl
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "办公用品申请管理-分页列表查询")
    @ApiOperation(value = "办公用品申请管理-分页列表查询")
    @GetMapping(value = "/list")
    public HttpResult<?> queryPageList(OaBgypsqgl oaBgypsqgl, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
        QueryWrapper<OaBgypsqgl> queryWrapper = QueryBuilder.initQueryWrapper(oaBgypsqgl, req.getParameterMap());
        Page<OaBgypsqgl> page = new Page<>(pageNo, pageSize);
        IPage<OaBgypsqgl> pageList = oaBgypsqglService.page(page, queryWrapper);
        for (OaBgypsqgl vo : pageList.getRecords()) {
            formatValue(vo);
        }
        return HttpResult.ok(pageList);
    }




    @AutoLog(value = "办公用品申请-编辑")
    @ApiOperation(value = "办公用品申请-编辑")
    @PutMapping(value = "/edit")
    public HttpResult<?> edit(@RequestBody OaBgypsqgl oaBgypsqgl) {
        oaBgypsqglService.updateById(oaBgypsqgl);
        return HttpResult.ok(I18nUtil.message("update.success"));
    }

    /**
     * 数据转换
     *
     * @param oaBgypsqgl
     */
    private void formatValue(OaBgypsqgl oaBgypsqgl) {
    }
}
